package com.javapatterns.xmlproperties;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;

import org.xml.sax.SAXException;

/**
 * 不能运行
 * 
 * @author yaoming
 * 
 */
public class TestXML {
	public static void main(String[] args) throws SAXException, IOException {
		XMLProperties xml = new XMLProperties();
		String path = System.getProperty("user.dir");
		path = path + "/src/main/javapattern/" + "xml2.xml";
		xml.load(new File(path));

		Enumeration keyEnum = xml.keys();
		Enumeration valueEnum = xml.elements();

		for (; keyEnum.hasMoreElements();) {
			String key = (String) keyEnum.nextElement();
			String value = (String) valueEnum.nextElement();

			System.out.println(key + "=" + value);
		}

		OutputStream out = new FileOutputStream(new File("c:/out.xml"));

		xml.store(out, "test");

	}
}
